const express = require("express");
const http = require("http");
const config = require("./config");
const router = require("./routers");
const initDb = require("./config/db").init;
const initMiddleware = require("./config/middleware");
const initSession = require("./config/session");
const app = require("express")();
const MongoClient = require('mongodb').MongoClient;

try {
  initMiddleware(app);
  initDb();
  initSession(app);
  router(app);
} catch (e) {
  console.log(e);
}

http.createServer(app).listen(config.port, '0.0.0.0', () => {
  console.log("start success, port:", config.port);
});
